import matplotlib.pyplot as plt

resultsDirectory = r"E:\sun2\工作\lab\遥感数据\paper\crowdsourcing label\figures\SVMResult\SVMResult\\"
precisions0 = []
turns0 = []
for i in range(108):
    with open(resultsDirectory+"SVM"+str(25+i*5)+"Result.txt") as f:
        f.readline()
        f.readline()
        f.readline()
        f.readline()
        line = f.readline()
        precisions0.append(float(line))
        turns0.append(i)

print(len(precisions0), precisions0)
print(len(turns0), turns0)

resultsDirectory = r"E:\sun2\工作\lab\遥感数据\paper\crowdsourcing label\figures\SVMSmoothResult\\"
precisions1 = []
turns1 = []
for i in range(108):
    with open(resultsDirectory+"SVM"+str(25+i*5)+"Result.txt") as f:
        f.readline()
        f.readline()
        f.readline()
        f.readline()
        line = f.readline()
        precisions1.append(float(line))
        turns1.append(i)
# precisions0.sort()
# precisions1.sort()
print(len(precisions1))
print(len(turns1))
fig = plt.figure(figsize=(12, 6), dpi=72, facecolor="white")
# axes = plt.subplot(111)
plot0 = plt.plot(turns0, precisions0, '-r', label="without smoothing", linewidth=2.0)
plot1 = plt.plot(turns1, precisions1, '-g', label="with smoothing", linewidth=2.0)
plt.xlabel("Round", fontsize=24)
plt.ylabel("Precision(%)", fontsize=24)
ax = plt.gca()
plt.xlim(xmax=107)
ax.set_xticks((0, 12, 24, 36, 48, 60, 72, 84, 96, 107))
ax.set_xticklabels(('0', '12', '24', '36', '48', '60', '72', '84', '96', '108'), fontsize=16)
ax.set_yticks((0.4, 0.45, 0.5, 0.55, 0.60, 0.65))
ax.set_yticklabels(('0.4', '0.45', '0.5', '0.55', '0.60', '0.65'), fontsize=16)
plt.legend(loc='lower right', fontsize=20)
plt.savefig("e:\\without ps.png")
plt.show()
